﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.out_storage
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int out_storage_id=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(out_storage_id);
				}
			}
		}
			
	private void ShowInfo(int out_storage_id)
	{
		lcs.BLL.out_storage bll=new lcs.BLL.out_storage();
		lcs.Model.out_storage model=bll.GetModel(out_storage_id);
		this.lblout_storage_id.Text=model.out_storage_id.ToString();
		this.txtmaterial_id.Text=model.material_id.ToString();
		this.txtposition_id.Text=model.position_id.ToString();
		this.txtout_storage_User_id.Text=model.out_storage_User_id.ToString();
		this.txtout_storage_Time.Text=model.out_storage_Time.ToString();
		this.txtout_storage_count.Text=model.out_storage_count.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtmaterial_id.Text))
			{
				strErr+="material_id格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtposition_id.Text))
			{
				strErr+="仓位编号格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtout_storage_User_id.Text))
			{
				strErr+="出库人员格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtout_storage_Time.Text))
			{
				strErr+="出库时间格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtout_storage_count.Text))
			{
				strErr+="出库数量格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int out_storage_id=int.Parse(this.lblout_storage_id.Text);
			int material_id=int.Parse(this.txtmaterial_id.Text);
			int position_id=int.Parse(this.txtposition_id.Text);
			int out_storage_User_id=int.Parse(this.txtout_storage_User_id.Text);
			DateTime out_storage_Time=DateTime.Parse(this.txtout_storage_Time.Text);
			decimal out_storage_count=decimal.Parse(this.txtout_storage_count.Text);


			lcs.Model.out_storage model=new lcs.Model.out_storage();
			model.out_storage_id=out_storage_id;
			model.material_id=material_id;
			model.position_id=position_id;
			model.out_storage_User_id=out_storage_User_id;
			model.out_storage_Time=out_storage_Time;
			model.out_storage_count=out_storage_count;

			lcs.BLL.out_storage bll=new lcs.BLL.out_storage();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
